<template>
  <h4>和是：{{x.y}}</h4>
  <button @click="x.y++">点我加一</button>
  <hr>
  <h2>原姓名：{{ person.name }}</h2>
  <h2>姓名：{{ person.name }}</h2>
  <h2>年龄：{{ person.age }}</h2>
  <h2>薪水:{{ person.job.j1.salary }}K</h2>
  
  <button @click="person.name += '!'">改名</button>
  <button @click="person.age++">增寿</button>
  <button @click="person.job.j1.salary++">加薪</button>
</template>

<script>
import { reactive, shallowReactive, ref, shallowRef } from "vue";
export default {
  name: "Demo",
  beforeCreate() {},

  setup(props, context) {

    let person = shallowReactive({
    //let person = reactive({
      name: "张三",
      age: 18,
      job: {
        j1: {
          salary: 20,
        },
      },
    });

    let x = shallowRef({
      y:1
    });

    return {
      x,
      person,
    };
  },
};
</script>